package com.atguigu.jxc.service.impl;

import com.atguigu.jxc.dao.CustomerReturnGoodsDao;
import com.atguigu.jxc.dao.CustomerReturnGoodsListDao;
import com.atguigu.jxc.entity.CustomerReturnList;
import com.atguigu.jxc.entity.CustomerReturnListGoods;
import com.atguigu.jxc.service.CustomerReturnService;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

@Service
public class CustomerReturnServiceImpl implements CustomerReturnService {

    @Autowired
    CustomerReturnGoodsDao customerReturnGoodsDao;

    @Autowired
    CustomerReturnGoodsListDao customerReturnGoodsListDao;


    @Override
    public Map<String, Object> list(String returnNumber, Integer customerId, Integer state,String sTime, String eTime) {

        List<CustomerReturnList> result = customerReturnGoodsDao.list(returnNumber,customerId,state,sTime,eTime);

        Map<String,Object> map = new HashMap<>();
        map.put("rows",result);
        return map;
    }

    @Override
    public Map<String, Object> goodsList(Integer customerReturnListId) {

        QueryWrapper<CustomerReturnListGoods> queryWrapper = new QueryWrapper<>();
        queryWrapper.eq("customer_return_list_goods_id",customerReturnListId);

        List<CustomerReturnListGoods> result = customerReturnGoodsListDao.selectList(queryWrapper);

        Map<String,Object> map = new HashMap<>();
        map.put("rows",result);

        return map;
    }

    @Override
    public void delete(Integer customerReturnListId) {

        customerReturnGoodsDao.delete(customerReturnListId);
    }
}
